//
//  TLDeviceManger.m
//  FunnyVideo
//
//  Created by 李鑫 on 15/9/19.
//  Copyright © 2015年 NewEggTech. All rights reserved.
//

#import "TLDeviceManger.h"
#import <UIKit/UIKit.h>
#import "sys/utsname.h"

@implementation TLDeviceManger
+ (CGSize)navigationBarSize{
    CGSize size = CGSizeMake([[UIApplication sharedApplication] statusBarFrame].size.width, 44);
    return size;
}
+ (CGSize)deviceScreenSize{
    return [[UIScreen mainScreen] bounds].size;
}

+ (BOOL)osVersionNewerThan:(float)osVersion{
    return ([[[UIDevice currentDevice] systemVersion] floatValue] > osVersion ? YES:NO);
}

+ (BOOL)osVersionOlderThan:(float)osVersion{
    return ([[[UIDevice currentDevice] systemVersion] floatValue] < osVersion ? YES:NO);
}

+ (BOOL)osVersionNewerOrEqualTo:(float)osVersion{
    return ([[[UIDevice currentDevice] systemVersion] floatValue] >= osVersion ? YES:NO);
}

+ (BOOL)osVersionOlderOrEqualTo:(float)osVersion{
    return ([[[UIDevice currentDevice] systemVersion] floatValue] <= osVersion ? YES:NO);
}
+ (CGFloat)screenScaleFactor{
    if([TLDeviceManger deviceScreenSize].height == 1334)
    return 0.56;
    else if ([TLDeviceManger deviceScreenSize].height == 1080)
        return 0.6;
    else if([TLDeviceManger deviceScreenSize].height == 960)
        return 0.47;
    else
        return 0.6;
}

+ (CGFloat)scaleFactor:(float)cell_scale andYPos:(float)yPos{
    static dispatch_once_t onceToken;
    static float scale = 0.5;
    
    dispatch_once(&onceToken, ^{
        scale = ((yPos+47)*cell_scale/[TLDeviceManger deviceScreenSize].height);
    });
    NSLog(@"scale factor %lf",scale);
    return 1-scale;
}
@end
